const user = {
    name:"houdunren",
    isLogin:false
}

const AccessDecorator:MethodDecorator = (target:Object, propertyKey:string | symbol,descriptor:PropertyDescriptor) => {
    const method = descriptor.value;
    descriptor.value = () => {
        if(user.isLogin == true){
            method();
        }else{
            alert("请登录后再操作！");
            location.href = 'login.html';
        }
    }
}

class Article{
    show(){
        console.log('显示文章');
    }

    @AccessDecorator
    storage(){
        console.log('保存文章');
    }
}

new Article().show();
new Article().storage();